<meta title="辣小客开放平台配置" args="data"/>
<style>

</style>
<form class="form-horizontal" id="form" s="form,datac,nda,valid" s-data="data" style="width: 600px;">
	<div class="form-group">
		<label class="col-sm-3 control-label">OPEN ID</label>
		<div class="col-sm-9">
			<input autocomplete="off" type="text" class="form-control" name="openId" placeholder="OPEN ID"
				   s-valid-error="require()"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">Api Url</label>
		<div class="col-sm-9">
			<input autocomplete="off" type="text" class="form-control" name="apiUrl" placeholder="Api Url"
				   s-valid-error="require()"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">京东联盟API类型</label>
		<div class="col-sm-9">
			<select class="form-control" s="select"
					name="jdUnionApiPermissionType"
					s-build="S.get('/api/enum/valuesMap/core.enums.JdUnionApiPermissionType')">
			</select>
		</div>
	</div>
	<div class="form-group">
		<div class="col-sm-offset-3">
			<input type="button" class="btn btn-primary btn-outline btn-sm" s-click="refreshJdAccessToken()" value="刷新京东授权" />
			<input type="button" class="btn btn-primary btn-outline btn-sm" s-click="refreshPddAccessToken()" value="刷新拼多多授权" />
		</div>
	</div>
</form>
<script type="text/javascript">
    S.getContent = function () {
        var deferred = $.Deferred();
        $form.validate().done(function () {
            deferred.resolve(Smart.serializeToObject($form.node))
        })
        return deferred;
    }

    function refreshJdAccessToken() {
        S.get("/api/laxiaoke-open/refresh-jd-access-token").done(function(rs) {
            if(rs) {
                S.toast("刷新成功")
            }
        })
    }

    function refreshPddAccessToken() {
        S.get("/api/laxiaoke-open/refresh-pdd-access-token").done(function(rs) {
            if(rs) {
                S.toast("刷新成功")
            }
        })
    }
</script>
